home *** CD-ROM | disk | FTP | other *** search
- // Copyright (C) 1997-2002 Alias|Wavefront,
- // a division of Silicon Graphics Limited.
- //
- // The information in this file is provided for the exclusive use of the
- // licensees of Alias|Wavefront. Such users have the right to use, modify,
- // and incorporate this code into other products for purposes authorized
- // by the Alias|Wavefront license agreement, without fee.
- //
- // ALIAS|WAVEFRONT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- // INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- // EVENT SHALL ALIAS|WAVEFRONT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
- // CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
- // DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
- // TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- // PERFORMANCE OF THIS SOFTWARE.
- //
- //
- // Alias|Wavefront Script File
- // MODIFY THIS AT YOUR OWN RISK
- //
- // Creation Date: March 13, 1997
- //
- // Description:
- // This script creates a bookmarkEditor for the Hyper Graph
- // as well as handling all the bookmarks for the Hyper Graph Menus
- //
- // Input Arguments:
- // parent
- //
- // Return Value:
- // None.
- //
- //
-
-
- global string $hyperBookmarks[];
- global int $hyperBookmarksInitialized = 0;
-
-
- global proc hyperViewer(string $editor)
- {
- global int $hyperBookmarksInitialized;
-
- if (`window -exists hyperBookmarkWindow`){
- showWindow hyperBookmarkWindow;
- hyperBookmarkUpdate($editor);
- } else {
- hyperBookmarkCreateUI($editor);
- }
-
- if (!$hyperBookmarksInitialized) {
- scriptJob -parent "hyperBookmarkWindow"
- -conditionTrue "deleteAllCondition"
- ("hyperBookmarkUpdate " + $editor);
- scriptJob -parent "hyperBookmarkWindow"
- -disregardIndex -attributeChange hyperGraphInfo.bookmarks
- ("hyperBookmarkUpdate " + $editor);
- $hyperBookmarksInitialized = 1;
- }
- }
-
-
- global proc hyperBookmarkCreateUI(string $editor)
- {
- // Create a new window
- window
- -title "Bookmarks"
- -iconName "Bookmarks"
- -width 150 -height 400
- -menuBar true
- -minimizeButton true
- -maximizeButton false
- hyperBookmarkWindow;
-
- hyperBookmarkMakeMenuBar($editor);
-
- formLayout hyperBookmarkEditorForm;
- formLayout hyperBookmarkListForm;
- setParent ..; // hyperBookmarkEditorForm;
- formLayout -height 30 hyperBookmarkButtonsForm;
- button -l "Create Bookmark"
- -c ("hyperBookmarkAddCallback " + $editor + " later")
- addBookmarkButton;
-
- formLayout -e
- -attachForm hyperBookmarkListForm right 0
- -attachForm hyperBookmarkListForm left 0
- -attachForm hyperBookmarkListForm top 0
- hyperBookmarkEditorForm;
-
- formLayout -e
- -attachForm hyperBookmarkButtonsForm right 0
- -attachForm hyperBookmarkButtonsForm left 0
- -attachForm hyperBookmarkButtonsForm bottom 0
- hyperBookmarkEditorForm;
-
- formLayout -e
- -attachControl hyperBookmarkListForm bottom 0 hyperBookmarkButtonsForm
- hyperBookmarkEditorForm;
-
- formLayout -e
- -af addBookmarkButton top 0
- -af addBookmarkButton left 0
- -af addBookmarkButton bottom 0
- -af addBookmarkButton right 0
- hyperBookmarkButtonsForm;
-
- hyperBookmarkUpdate($editor);
- showWindow hyperBookmarkWindow;
- }
-
-
- global proc hyperBookmarkMakeMenuBar(string $editor)
- {
- menu -l "Edit" -aob true;
- menuItem
- -l "Create Bookmark"
- -command ("hyperBookmarkAddCallback " + $editor + " later")
- hyperBookmarkAddMenuItem;
- menuItem -ob true
- -command ("hyperBookmarkAddCallback " + $editor + " first")
- hyperBookmarkAddMenuOBItem;
- menuItem
- -l "Delete Bookmark"
- -command ("hyperBookmarkDeleteCallback " + $editor)
- hyperBookmarkDeleteMenuItem;
- menuItem
- -l "Delete All Bookmarks"
- -command ("hyperBookmarkDeleteAllCallback " + $editor)
- hyperBookmarkDeleteAllMenuItem;
- menuItem
- -l "Rename Bookmark..."
- -command ("hyperBookmarkRenameCallback " + $editor)
- hyperBookmarkRenameMenuitem;
- }
-
-
- global proc hyperBookmarkUpdate(string $editor)
- {
- global string $hyperBookmarks[];
-
- if (`window -exists hyperBookmarkWindow`) {
- if(`about -mac`) {
- setParent
- ("hyperBookmarkWindow|hyperBookmarkWindow|" +
- "hyperBookmarkEditorForm|" +
- "hyperBookmarkListForm");
- } else {
- setParent
- ("hyperBookmarkWindow|" +
- "hyperBookmarkEditorForm|" +
- "hyperBookmarkListForm");
- }
- if (`textScrollList -exists sl`){
- deleteUI sl;
- }
-
- formLayout -e -visible false hyperBookmarkListForm;
-
- textScrollList -height 100
- -allowMultiSelection no
- -allowAutomaticSelection yes
- sl;
-
- formLayout -e
- -attachForm sl top 0
- -attachForm sl left 0
- -attachForm sl bottom 0
- -attachForm sl right 0
- hyperBookmarkListForm;
- $hyperBookmarks = `listConnections hyperGraphInfo.bookmarks`;
- string $description;
-
- for ($item in $hyperBookmarks) {
- $description = `getAttr ($item + ".description")`;
- if ($description == "")
- $description = $item;
-
- textScrollList -e -a $description sl;
- }
-
- textScrollList -e
- -selectCommand ("hyperBookmarkSelectCallback " + $editor)
- sl;
- textScrollList -e
- -doubleClickCommand ("hyperBookmarkRenameCallback " + $editor)
- sl;
- textScrollList -e
- -deleteKeyCommand ("hyperBookmarkDeleteCallback " + $editor)
- sl;
-
- formLayout -e -visible true hyperBookmarkListForm;
-
- setParent ..;
- }
- }
-
-
- global proc hyperBookmarkSelectCallback(string $editor)
- //
- // Callback for selecting hyperGraph bookmarks.
- //
- {
- global string $hyperBookmarks[];
- int $item[1] = `textScrollList -q -selectIndexedItem sl`;
- hyperGraph -e -restoreBookmark
- $hyperBookmarks[$item[0]-1] $editor;
- }
-
-
- global proc hyperBookmarkRenameCallback(string $editor)
- //
- // Callback for renaming hyperGraph bookmarks.
- // Check first whether something is selected
- //
- {
- string $selectedItem[] = `textScrollList -q -si sl`;
- if (`size($selectedItem)` == 0) {
- return;
- }
- else {
- global string $hyperBookmarks[];
- string $description;
-
- int $item[1] = `textScrollList -q -selectIndexedItem sl`;
-
- $description =
- `getAttr ($hyperBookmarks[$item[0]-1] + ".description")`;
-
- string $result = `promptDialog
- -title "Rename Bookmark"
- -message "Rename Bookmark:"
- -text (textScrollList ("-q", "-selectItem", "sl"))
- -defaultButton "OK"
- -button "OK"
- -button "Cancel"`;
- if ($result == "OK") {
- setAttr ($hyperBookmarks[$item[0]-1] + ".description")
- -type "string"
- `promptDialog -q -tx`;
- }
- hyperBookmarkUpdate($editor);
- }
- }
-
-
- global proc hyperBookmarkDeleteCallback(string $editor)
- //
- // Callback for deleting hyperGraph bookmarks.
- // Check first whether something is selected
- //
- {
- string $selectedItem[] = `textScrollList -q -si sl`;
- if (`size($selectedItem)` == 0) {
- return;
- }
- else {
- global string $hyperBookmarks[];
-
- int $item[1] = `textScrollList -q -selectIndexedItem sl`;
- textScrollList -e -rii $item[0] sl;
- hyperGraph -e -deleteBookmark $hyperBookmarks[$item[0]-1]
- $editor;
- hyperBookmarkUpdate($editor);
- }
- }
-
- global proc hyperBookmarkDeleteAllCallback(string $editor)
- //
- // Callback for deleting all hyperGraph bookmarks.
- //
- {
- string $allItems[] = `textScrollList -q -ai sl`;
- int $numItems = size($allItems);
- if ($numItems == 0) {
- return;
- }
- else {
- global string $hyperBookmarks[];
- textScrollList -e -ra sl;
- for ($i = $numItems-1; $i >= 0; $i--) {
- hyperGraph -e -deleteBookmark $hyperBookmarks[$i] $editor;
- }
- hyperBookmarkUpdate($editor);
- }
- }
-
-
- global proc hyperBookmarkAddCallback(string $editor, string $renameWhen)
- //
- // Callback for adding hyperGraph bookmarks.
- //
- {
- string $newBookmarkName;
- string $newBookmark;
-
- if ($renameWhen == "first"){
- string $result = `promptDialog
- -title "Name Bookmark"
- -message "Name Bookmark:"
- -text "Bookmark Name"
- -defaultButton "OK"
- -button "OK"
- -button "Cancel"`;
- if ($result == "OK") {
- $newBookmarkName = `promptDialog -q -tx`;
- hyperGraph -e -addBookmark $editor;
- $newBookmark =
- `hyperGraph -q -bookmarkName $editor`;
- setAttr ($newBookmark + ".description")
- -type "string" $newBookmarkName;
- hyperBookmarkUpdate($editor);
- }
- } else {
- hyperGraph -e -addBookmark $editor;
- hyperBookmarkUpdate($editor);
- }
- }
-
-
-
- global proc hyperBookmarkRenameMenuCallback(string $editor, string $nodeName)
- //
- // Callback for renaming hyperGraph menuBookmarks.
- //
- {
- string $userName =
- `getAttr ($nodeName + ".description")`;
- if ($userName == "") {
- $userName = $nodeName;
- }
- string $result = `promptDialog
- -title "Rename Bookmark"
- -message "Rename Bookmark:"
- -text $userName
- -defaultButton "OK"
- -button "OK"
- -button "Cancel"`;
- if ($result == "OK") {
- setAttr ($nodeName + ".description")
- -type "string"
- `promptDialog -q -tx`;
- }
- hyperBookmarkUpdate($editor);
- }
-
-
- global proc hyperBookmarkBuildMenu(string $editor, string $parent)
- {
- global string $hyperBookmarks[];
-
- setParent -menu $parent;
-
- menu -e -deleteAllItems $parent;
-
- menuItem -label "Create Bookmark"
- -command ("hyperBookmarkAddCallback " + $editor + " later")
- saveBMItem;
- menuItem -ob true
- -command ("hyperBookmarkAddCallback " + $editor + " first");
- menuItem -label "Bookmark Editor..."
- -command ("hyperViewer " + $editor)
- bookmarkEditor;
- menuItem -divider true;
-
- // Create a menu item for each bookmark
- string $bookmarks[] = `listConnections hyperGraphInfo.bookmarks`;
- string $description;
- string $nodeName;
-
- for ($item in $bookmarks) {
- $nodeName = $item;
- $description = `getAttr ($item + ".description")`;
-
- if ($description == ""){
- $description = $item;
- }
- menuItem -l $description
- -command
- ("hyperGraph -e -restoreBookmark " + $item + " " + $editor);
- menuItem -ob true
- -command ("hyperBookmarkRenameMenuCallback "
- + $editor + " " + $nodeName);
- }
- }
-
-
-